package com.xiaofeng.pochi.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xiaofeng.pochi.common.Page;
import com.xiaofeng.pochi.pojo.ShopProduct;
import com.xiaofeng.pochi.pojo.ShopProductCategory;
import com.xiaofeng.pochi.pojo.vo.ShopProductVo;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created with IntelliJ IDEA
 *
 * @Author: chc
 * @Date: 2022/08/10/23:28
 * @Description:
 */
@Component
public interface ShopProductMapper extends BaseMapper<ShopProduct> {
    /**
     * 保存
     * @param shopProduct
     */
    void save(ShopProduct shopProduct);

    /**
     * 分页查询
     *
     * @param page
     * @return
     */
    List<ShopProduct> getByPage(Page<ShopProductVo> page);

    /**
     * 查询总数
     *
     * @param page
     * @return
     */
    Integer countByPage(Page<ShopProductVo> page);


    /**
     * 根据id查询
     *
     * @param id
     * @return
     */
    ShopProduct getById(Long id);

    /**
     * 修改
     *
     * @param shopProduct
     */
    void update(ShopProduct shopProduct);

    /**
     * 删除
     *
     * @param id
     */
    void delete(Long id);

    void updatePublish(ShopProduct product);

    void updateNewStatus(ShopProduct product);

    void updateRecommend(ShopProduct product);

    List<ShopProduct> getByIds(List<Long> productIds);

    List<ShopProduct> getByPageHasNotPack(Page<ShopProductVo> page);

    Integer countByPageHasNotPack(Page<ShopProductVo> page);

    List<ShopProduct> getNewProduct();

    /**
     * 查询推荐商品
     * @return
     */
    List<ShopProduct> getRecommendList();

    /**
     * 根据id查询基本信息
     * */
    ShopProduct getInfoById(Long productId);

    /**
     * 查询所在类目下销量最高的6条数据
     * @param categoryId
     * @return
     */
    List<ShopProduct> getRankByCategory(Long categoryId);

    /**
     * 扣减库存
     * @param product
     */
    void updateStock(ShopProduct product);
}
